package com.eqdd.yiqidian.ui.discover.gonggao;

import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.View;

import com.eqdd.yiqidian.Fragment1Custom;
import com.eqdd.yiqidian.R;
import com.eqdd.yiqidian.adapter.slimadapter.SlimAdapterEx;
import com.eqdd.yiqidian.adapter.slimadapter.SlimInjector;
import com.eqdd.yiqidian.adapter.slimadapter.viewinjector.IViewInjector;
import com.eqdd.yiqidian.base.BaseFragment;
import com.eqdd.yiqidian.bean.SecondBean;

import java.util.ArrayList;

/**
 * Created by lvzhihao on 17-6-21.
 */

public class GuangboFragment extends BaseFragment {
    private Fragment1Custom dataBinding;
    private ArrayList<SecondBean> secondBeen;
    private SlimAdapterEx slimAdapterEx;

    @Override
    protected void setView() {

        dataBinding.recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        slimAdapterEx = SlimAdapterEx.create().register(R.layout.list_item_05, new SlimInjector<SecondBean>() {
            @Override
            public void onInject(SecondBean data, IViewInjector injector) {

                injector.text(R.id.tv_left_center_content,data.getFirst())
                        .text(R.id.tv_right_center_content,data.getSecond())
                        .invisible(R.id.iv_enter);
            }
        }).attachTo(dataBinding.recyclerView);
        slimAdapterEx.updateData(secondBeen);

    }

    @Override
    protected void initData() {

        secondBeen = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            SecondBean secondBean = new SecondBean("春节放假", "2017-2-15");
            secondBeen.add(secondBean);
        }
    }

    @Override
    public ViewDataBinding initBinding(LayoutInflater inflater) {
        return dataBinding=DataBindingUtil.inflate(inflater, R.layout.fragment_1,null,false);
    }

    @Override
    public void onClick(View v) {

    }
}
